
<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "addEventForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
$url = $control->getAjaxLinkUrl('saveEvent', NULL, array(
    'eventId' => $eventId));
$updateId = $control->getAjaxContainerId();
?>
<script type="text/javascript">
// this script for collecting the form data and pass to the controller action and doing the on success validations
    function saveEvent<?php echo $eventId; ?>() {
        var eventName = $('#BDynamicFormModel_media_name_event_info').val();
        var eventDescription = $('#BDynamicFormModel_media_description_event_info').val();
        var eventManageView = $('#BDynamicFormModel_media_manageView_event_info').val();
        if (eventName != "") {
            if (eventDescription != "") {
                if (eventManageView != "") {
                    var formData = new FormData($("#addEventForm")[0]);
                    $.ajax({
                        url: '<?php echo $url; ?>',
                        type: 'POST',
                        data: formData,
                        //datatype: 'json',
                        // async: false,
                        beforeSend: function() {
                            $("#ajax-loaderdiv").show();
                        },
                        success: function(html) {
                            // on success do some validation or refresh the content div to display the uploaded images 
                            jQuery("#<?php echo $updateId; ?>").html(html);
                        },
                        complete: function() {
                            $("#ajax-loaderdiv").hide();
                        },
                        error: function(data) {
                            alert("There may a error on uploading. Try again later");
                        },
                        cache: false,
                        contentType: false,
                        processData: false
                    });
                } else
                    alert("请输入管理首页")
            } else
                alert("请输入活动描述");
        } else
            alert("活动名称");
        return false;
    }
</script>
<legend>
    <h4>

<?php echo $control->getAjaxLink(array('name' => '活动列表', 'id' => 'showAdmin')); ?>\       
        <?php echo '设置活动'; ?>
    </h4>
</legend>

<?php
$control->renderView('event_add_info', array(
    'eventId' => $eventId));
?>  

<?php
$this->endWidget();
//echo CHtml::endForm();
?>
<button class="btn" onclick="javascript:saveEvent<?php echo $eventId; ?>()"><?php echo '保存活动' ?></button>


